<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>创业者服务首页</title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
		<link rel="stylesheet" href="../css/leftSidebar.css">
	</head>
	<style type="text/css">
        html,body{height: 100%;padding-bottom: 50px;}
		.col-xs-12.nav_right{padding: 0;height: 100px;padding-right: 0;margin-right: 0;min-width: 1100px;height: 100px;padding-right: 0;margin-right: 0;padding-left: 160px;}
		#myTab a{color: #7c7c7c;font-family: "微软雅黑";font-size: 15px;}
		#myTab>li.active>a{color: #3f4142; background-color: #fff;}
		.navbar-form{margin-top: 0;}
		.tab_creat .active{color:#6bc50d;}
		.table>tbody>tr.active>td, .table>tbody>tr.active>th, .table>tbody>tr>td.active, .table>tbody>tr>th.active, .table>tfoot>tr.active>td, .table>tfoot>tr.active>th, .table>tfoot>tr>td.active, .table>tfoot>tr>th.active, .table>thead>tr.active>td, .table>thead>tr.active>th, .table>thead>tr>td.active, .table>thead>tr>th.active{background-color: #fff;}
		.table>tfoot>tr.active>td{background-color: #fff;}
		.table>tbody>tr>td{border-top:0;}
		.table{margin-bottom: 0;}
		div.tab_creat.row{background-color: #fff;}
		.tab_font{padding: 10px 0;}
		.tab_font div,.tab_font td{font-size: 14px;color: #919191;}
		.gongsi_list div.col-xs-2,.gongsi_list div.col-xs-3,.gongsi_list div.col-xs-1{text-align: center;padding: 20px 0;}
		.gongsi_list.row{background-color: #fff;margin-top: 20px;}
		.gongsi_list dd div.col-xs-2{font-size: 14px;color: #4f5051;}
		.row{margin: 0;}
		.sub_logo{position: relative;display: inline-block;padding-left: 0;}
		.sub_logo input{opacity: 0;position: absolute;left: 0;right: 0;bottom: 0;top: 0;}
		.zhube_head{border-bottom: 1px solid #ddd;}
		.zhube_head h3{padding: 5px 0;,font-family: "微软雅黑";color: #222c38;font-size: 16px;border-bottom: 4px solid #5a626d;}
			
		#form_test label{font-size: 14px;font-family: "微软雅黑";color: #515151;font-weight: normal;}
		#form_test  .media-middle{font-size: 14px;color: #acacac;}
		.form_tip{font-size: 12px;color: #acacac;font-family: "微软雅黑";}
		.btn-default{border-color: #6bc50d;color: #6bc50d;}
		.btn-default.disabled{background-color: #ccc;color: #fff;border-color:#ccc;}
		.btn-default.disabled.focus, .btn-default.disabled:focus, .btn-default.disabled:hover, .btn-default[disabled].focus, .btn-default[disabled]:focus, .btn-default[disabled]:hover, fieldset[disabled] .btn-default.focus, fieldset[disabled] .btn-default:focus, fieldset[disabled] .btn-default:hover{background-color: #ccc;color: #fff;}
		
		.panel-title{font-size: 18px;color: #222c38;font-weight: bold;}
	</style>
	<body style="background-color: #f2f2f2;">
		<div class="row warp" style="height: 100%;">
			<div class="nav_right_head">
				<a href="../index.html"><img src="../img/roleIndexBg.jpg"/></a>
			</div>
			<!--左侧导航-->
			<div class="col-xs-2 nav_left">
				<div class="creatNav">创业者服务</div>
				<div class="creatLoginStatus"><img src="../img/avtar.png"><a>您好，创业者</a></div>
				<div class="list-group" style="padding: 0;">
					<a href="cyzfw_index.html" class="list-group-item "><i class="glyphicon glyphicon-home"></i> 首页</a>
					<a href="cyzfw_zuche.html" class="list-group-item"><i class="glyphicon glyphicon-plus-sign"></i> 注册项目</a>
					<a href="cyzfw_myProgress.html" class="list-group-item"><i class="glyphicon glyphicon-folder-open"></i> 我的项目</a>
					<a href="cyzfw_mynews.html" class="list-group-item"><i class="glyphicon glyphicon-book"></i> 我的消息</a>
					<div class="list-group listAttention">
						<div class="list-group-item" > <span class="caret"></span> 我的关注</div>
						<a href="cyzfw_gz_touziren.html" class="list-group-item"><i class="glyphicon glyphicon-usd"></i> 投资人/机构</a>
						<a href="cyzfw_gz_daoshi.html" class="list-group-item active	"><i class="glyphicon glyphicon-user"></i> 导师</a>
						<a href="cyzfw_gz_xiangmu.html" class="list-group-item"><i class="glyphicon glyphicon-lock"></i> 项目</a>
					</div>

				</div>
				<div class="backBtn"> <a href="../index.html"><img src="../img/backIndex.png"></a></div>
			</div>
			
			<div class="col-xs-12 nav_right" style="">
				<div class="row" style="margin-top: 10px;">
				    <div class="col-xs-10 col-xs-offset-1" >
					<div class="panel panel-default">
					  <div class="panel-heading">
					    <h3 class="panel-title">我关注的导师 </h3>
					  </div>
					  <div class="panel-body" style="padding: 0;">
					    <div class="row gongsi_list">
							<dl style="background-color: #fff;">
										<dt>
											<div class="row">
												<div class="col-xs-2" >导师</div>
												<div class="col-xs-2">辅导案例</div>
												<div class="col-xs-2">研究领域</div>
												<div class="col-xs-2">学历</div>
												<div class="col-xs-2">职位</div>
												<div class="col-xs-2">操作</div>
											
											</div>
										</dt>
								<div>
									<div id="daoshi_list"></div>
									<ul class="pagination pull-right" id="pageTutor">

									</ul>
								</div>
										<!--<dd>-->
											<!--<div class="row">-->
												<!--<div class="col-xs-3" style="padding-top: 10px;">-->
													<!--<div class="media">-->
													  <!--<div class="media-left media-middle" style="padding: 0px 15px;">-->
													     <!--<img src="../img/44.jpg" style="width: 40px;height: 40px;"/>-->
													  <!--</div>-->
													  <!--<div class="media-body text-left">-->
													     <!--<span style="display: inline-block;margin-top: 10px;"><a href="cyzfw_ckds.html">唐鑫</a></span>-->
										<!---->
													  <!--</div>-->
													<!--</div>-->
													<!--</div>-->
													<!---->
												<!--<div class="col-xs-2">3</div>-->
												<!--<div class="col-xs-2">生活消费</div>-->
												<!--<div class="col-xs-1">硕士</div>-->
												<!--<div class="col-xs-2">职位</div>-->
								<!---->
													<!--<div class="col-xs-2"><span>关注</span>  </div>			-->
											<!--</div>-->
										<!---->
										<!--</dd>-->
										

										

										</dd>
									
										
									</dl>

						</div>
					  </div>
					</div>
					</div>

			
				</div>
					
		</div>
		</div>
	</body>
	<script src="../js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js" ></script>
	<script type="text/javascript" src="../js/bootstrap-paginator.min.js"></script>
	<script type="text/javascript" src="../js/public.js"></script>

	<script type="text/javascript">
		var person = JSON.parse(sessionStorage.getItem("person"));
		if (person==''||person==null) {
//			alert('请先登录')
//			 window.location.href='denglu.html';
		} else{
			var userId = person.userid;
			console.log(userId);

		}

		getTutorList({'userId':userId},1,10);
		function getTutorList(objs,page,pageSize) {
			objs.index=page;
			objs.size=pageSize;
			$.ajax({
				type: "get",
				data:objs,
				url:"http://114.112.96.184:18080/auth/attentionTutors",
				async: false,
				error: function(request) {
					console.log("Connection error");
				},
				success: function(data) {
					console.log(data);
					var pages=Math.ceil(data.result.totalElements/10);
					if(pages<=1){
						$("#pageTutor").hide();
					}else{
						$("#pageTutor").show();
					}
					var options= {
						bootstrapMajorVersion: 3,
						currentPage: page,    //当前页数
						numberOfPages: 10,
						totalPages: pages,    //所有数据可以显示的页数
						tooltipTitles: function () {
						},
						itemTexts: function (type, page, current) {
							switch (type) {
								case "prev":
									return "←上一页";
								case "next":
									return "下一页→";
								case "page":
									return page;
							}
						},
						shouldShowPage: function (type, page, current) {
							switch (type) {
								case "first":
								case "last":
									return false;
								default:
									return true;
							}
						},
						onPageClicked: function (event, originalEvent, type, page) {
							objs.index=page;
							$.ajax({
								type: "get",
								data: {'userId': userId, 'index': page, 'size': pageSize},
								url: "http://114.112.96.184:18080/auth/attentionTutors",
								async: false,
								error: function (request) {
									console.log("Connection error");
								},
								success: function (data) {
									var obj = data.result.content;
									var htmls='';
									for (var i = 0; i < obj.length;i++) {
										var attention='';
										var createTime='';
										if (obj[i].attention==true) {
											attention='取消关注'
										} else{
											attention='关注'
										}
										if(obj[i].userId==userId){
											attention='我';
										}
										htmls+= '<dd>'+
												'<div class="row">'+
												'<div class="col-xs-2" style="padding-top:3px ;"><img src="'+obj[i].avatar +'" onerror="onErrorHandle(this)" style="width: 40px;height: 40px;"/> <a href="cyzfw_ckds.html?'+ obj[i].id +'">'+ obj[i].realName+'</a></div>'+
												'<div class="col-xs-2">'+obj[i].case+'</div>'+
												'<div class="col-xs-2">'+ obj[i].researchField+'</div>'+
												'<div class="col-xs-2">'+ obj[i].education+'</div>'+
												'<div class="col-xs-2">'+ obj[i].title+'</div>'+
												'<div class="col-xs-2 attentionTutor" attentionId="'+obj[i].id+'">'+ attention +'</div>'+
												'</div>'+
												'</dd>'
									}
									$('#daoshi_list').html(htmls);
								}
							})


						}
					}

					if(data.result.totalElements>0){
						$("#pageTutor").bootstrapPaginator(options);
					}

					var obj = data.result.content;
					var htmls='';
					for (var i = 0; i < obj.length;i++) {
						var attention='';
						var createTime='';
						if (obj[i].attention==true) {
							attention='取消关注'
						} else{
							attention='关注'
						}
						htmls+= '<dd>'+
								'<div class="row">'+
								'<div class="col-xs-2" style="padding-top:3px ;"><img src="'+obj[i].avatar +'" onerror="onErrorHandle(this)" style="width: 40px;height: 40px;"/> <a href="cyzfw_ckds.html?'+ obj[i].id +'">'+ obj[i].realName+'</a></div>'+
								'<div class="col-xs-2">'+obj[i].case+'</div>'+
								'<div class="col-xs-2">'+ obj[i].researchField+'</div>'+
								'<div class="col-xs-2">'+ obj[i].education+'</div>'+
								'<div class="col-xs-2">'+ obj[i].title+'</div>'+
								'<div class="col-xs-2 attentionTutor" attentionId="'+obj[i].id+'">'+ attention +'</div>'+
								'</div>'+
								'</dd>'
					}
					$('#daoshi_list').html(htmls);

				}
			});
		}

		//关注导师
		$(document).on('click','.attentionTutor',function () {
			if (person==''||person==null) {
				window.location.href='denglu.html';
				return;
			}
			if ($(this).text()=='我'){
				return false;
			}
			var id = $(this).attr('attentionId');
			if($(this).text()=='关注'){
				$(this).text('取消关注')
			}else {
				$(this).parent().parent().remove();
			}
			attentionTutor();
			function attentionTutor() {
				$.ajax({
					type: "post",
					data:{'userId':userId},
					url:"http://114.112.96.184:18080/auth/attentionTutor/"+id,
					async: false,
					error: function(request) {
						console.log("Connection error");
					},
					success: function(data) {
						console.log(data);

					}
				});
			}

		});
	</script>
</html>
